package com.holly.unit.bpmn.designer.enums;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * 类描述: 审批类型枚举
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/5/7 8:31
 */
public enum ApprovalTypeEnum {

    // 指定人员 审批
    ASSIGN_USER("user"),
    // 发起人自选 审批
    SELF_SELECT("SELF_SELECT"),
    //  连续多级主管 审批
    LEADER_TOP("LEADER_TOP"),
    // 主管 审批
    LEADER("LEADER"),
    // 角色 审批
    ROLE("role"),
    // 手动输入
    INPUT("input"),
    // 发起人自己 审批
    SELF("myself");

    String fieldName;

    ApprovalTypeEnum(String fieldName) {
        this.fieldName = fieldName;
    }

    public String fieldName() {
        return this.fieldName;
    }

    public static ApprovalTypeEnum of(String fieldName) {
        return Stream.of(ApprovalTypeEnum.values())
                .filter(clazz -> Objects.equals(clazz.fieldName(), fieldName))
                .findFirst()
                .orElse(ASSIGN_USER);
    }
}
